<%--
  Created by IntelliJ IDEA.
  User: WDD
  Date: 2019/6/17
  Time: 9:24
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">

    <link rel="stylesheet" href="${APP_PATH}/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="${APP_PATH}/css/font-awesome.min.css">
    <link rel="stylesheet" href="${APP_PATH}/css/main.css">
    <link rel="stylesheet" href="${APP_PATH }/css/pagination.css">
    <style>
        .tree li {
            list-style-type: none;
            cursor:pointer;
        }
        table tbody tr:nth-child(odd){background:#F4F4F4;}
        table tbody td:nth-child(even){color:#C00;}
    </style>
</head>

<body>

<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
    <div class="container-fluid">
        <div class="navbar-header">
            <div><a class="navbar-brand" style="font-size:32px;" href="#">众筹平台 - 项目审核</a></div>
        </div>
        <div id="navbar" class="navbar-collapse collapse">
            <ul class="nav navbar-nav navbar-right">
                <jsp:include page="/WEB-INF/jsp/common/top.jsp"></jsp:include>
            </ul>
            <form class="navbar-form navbar-right">
                <input type="text" class="form-control" placeholder="Search...">
            </form>
        </div>
    </div>
</nav>

<div class="container-fluid">
    <div class="row">
        <div class="col-sm-3 col-md-2 sidebar">
            <div class="tree">
                <jsp:include page="/WEB-INF/jsp/common/menu.jsp"></jsp:include>
            </div>
        </div>
        <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title"><i class="glyphicon glyphicon-th"></i> 数据列表</h3>
                </div>
                <div class="panel-body">
                    <form class="form-inline" role="form" style="float:left;">
                        <div class="form-group has-feedback">
                            <div class="input-group">
                                <div class="input-group-addon">查询条件</div>
                                <input class="form-control has-success" type="text" placeholder="请输入查询条件">
                            </div>
                        </div>
                        <button type="button" class="btn btn-warning"><i class="glyphicon glyphicon-search"></i> 查询</button>
                    </form>
                    <br>
                    <hr style="clear:both;">
                    <div class="table-responsive">
                        <table class="table  table-bordered">
                            <thead>
                            <tr >
                                <th width="30">#</th>
                                <th>项目名称</th>
                                <th>发起人ID</th>
                                <th>目标金额（元）</th>
                                <th>众筹周期(天)</th>
                                <th>创建时间</th>
                                <th>状态</th>
                                <th width="120">操作</th>
                            </tr>
                            </thead>
                            <tbody>

                            </tbody>
                            <tfoot>
                            <tr >
                                <td colspan="8" align="center">
                                    <div id="Pagination" class="pagination"><!-- 这里显示分页 --></div>
                                </td>
                            </tr>

                            </tfoot>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script src="${APP_PATH}/jquery/jquery-2.1.1.min.js"></script>
<script src="${APP_PATH}/bootstrap/js/bootstrap.min.js"></script>
<script src="${APP_PATH}/script/docs.min.js"></script>
<script type="text/javascript" src="${APP_PATH }/jquery/layer/layer.js"></script>
<script type="text/javascript" src="${APP_PATH }/script/menu.js"></script>
<script src="${APP_PATH}/jquery/pagination/jquery.pagination.js"></script>
<script type="text/javascript">
    $(function () {
        $(".list-group-item").click(function(){
            if ( $(this).find("ul") ) {
                $(this).toggleClass("tree-closed");
                if ( $(this).hasClass("tree-closed") ) {
                    $("ul", this).hide("fast");
                } else {
                    $("ul", this).show("fast");
                }
            }
        });

        showMenu();

        //异步加载用户列表
        queryPage(0);  //传的时索引
    });



    var jsonObj = {"pageno":1,"pagesize":10};

    //异步加载管理员列表
    function queryPage(pageIndex) {
        jsonObj.pageno = pageIndex+1;
        $.ajax({
            type:"POST",
            data:jsonObj,
            url:"${APP_PATH}/auth_project/doIndex.do",
            success:function (result) {
                if(result.success){
                    var page = result.page;
                    var data = page.datas;

                    var content = '';

                    $.each(data,function(i,n){

                        var status = "";
                        if(n.status == "0") status = "发起审核";
                        if(n.status == "1") status = "审核通过";
                        if(n.status == "2") status = "审核未通过";
                        if(n.status == "3") status = "众筹成功";
                        if(n.status == "4") status = "众筹失败";



                        content += '<tr>'
                        content += '    <td>'+(i+1)+'</td>'
                        content += '    <td>'+n.name+'</td>'
                        content += '    <td>'+n.memberid+'</td>'
                        content += '    <td>'+n.money+'</td>'
                        content += '    <td>'+n.day+'</td>'
                        content += '    <td>'+n.createdate+'</td>'
                        content += '    <td>'+status+'</td>'
                        content += '    <td>'
                        content += '        <button type="button" class="btn btn-success btn-xs"  onclick="pass('+n.id+')" >通过</button>'
                        content += '        <button type="button" class="btn btn-danger btn-xs" onclick="dispass('+n.id+')"  >不通过</button>'
                        content += '    </td>'
                        content += '</tr>'

                    });
                    $("tbody").html(content);

                    // 创建分页
                    $("#Pagination").pagination(page.totalsize, {
                        num_edge_entries: 1, //边缘页数
                        num_display_entries: 2, //主体页数
                        callback: queryPage,
                        items_per_page:page.pagesize, //每页显示1项
                        current_page:(page.pageno-1),
                        prev_text : "上一页",
                        next_text : "下一页"
                    });

                }else{

                }
            }

        })
    };


    //模糊查询
    $("#queryBtn").click(function (){
        var queryText = $("#queryText").val();
        jsonObj.queryText = queryText;
        queryPage(0)
    });

    function pass(id) {
        $.ajax({
            type: "POST",
            data: {"id":id},
            url: "${APP_PATH}/auth_project/pass.do",
            success:function (message) {
                if (message.success){
                    window.location.href = "${APP_PATH}/auth_project/index.htm";
                }else{

                }
            }
        });
    }

    function dispass(id) {
        $.ajax({
            type: "POST",
            data: {"id":id},
            url: "${APP_PATH}/auth_project/dispass.do",
            success:function (message) {
                if (message.success){
                    window.location.href = "${APP_PATH}/auth_project/index.htm";
                }else{

                }
            }
        });
    }

</script>
</body>
</html>

